BASE:=$(shell pwd | xargs basename)
CPPFLAGS = -I. -I ../../include
CPPSOURCES=${wildcard *.cpp}
VERSION=?-g

EXTENSION=
ifeq ($(VERSION),-g)
EXTENSION=-g
endif

OBJECTS=$(patsubst %.cpp,%$(EXTENSION).o,$(CPPSOURCES))

ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
-include $(SOURCE_DEPENDENCIES)
endif

../../lib/lib$(BASE)$(EXTENSION).a: $(OBJECTS)
	ar rcs $@ $(OBJECTS)
	rm $<
%$(EXTENSION).o:%.cpp
	ag++ -c $(EXTENSION) $< $(CPPFLAGS) -o $@
	cp $@ ../../.objs

echo:
	@echo $(OBJECTS)
	@echo $(CPPSOURCES)

clean:
	rm -f *.o *.d
